<?php

/**
 * This is the model class for table "v_item".
 *
 * The followings are the available columns in table 'v_item':
 * @property string $ID
 * @property string $item_author
 * @property string $item_date
 * @property string $item_date_gmt
 * @property string $item_content
 * @property string $item_title
 * @property string $item_excerpt
 * @property string $item_status
 * @property string $comment_status
 * @property string $item_password
 * @property string $item_name
 * @property string $item_modified
 * @property string $item_modified_gmt
 * @property string $item_content_filtered
 * @property string $item_parent
 * @property integer $menu_order
 * @property string $item_type
 * @property string $item_mime_type
 * @property string $comment_count
 */
class Item extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'v_item';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('item_content, item_title, item_excerpt, item_content_filtered', 'required'),
			array('menu_order', 'numerical', 'integerOnly'=>true),
			array('item_author, item_status, comment_status, item_password, item_parent, item_type, comment_count', 'length', 'max'=>20),
			array('item_name', 'length', 'max'=>200),
			array('item_mime_type', 'length', 'max'=>100),
			array('item_date, item_date_gmt, item_modified, item_modified_gmt', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('ID, item_author, item_date, item_date_gmt, item_content, item_title, item_excerpt, item_status, comment_status, item_password, item_name, item_modified, item_modified_gmt, item_content_filtered, item_parent, menu_order, item_type, item_mime_type, comment_count', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'ID' => 'ID',
			'item_author' => 'Item Author',
			'item_date' => 'Item Date',
			'item_date_gmt' => 'Item Date Gmt',
			'item_content' => 'Item Content',
			'item_title' => 'Item Title',
			'item_excerpt' => 'Item Excerpt',
			'item_status' => 'Item Status',
			'comment_status' => 'Comment Status',
			'item_password' => 'Item Password',
			'item_name' => 'Item Name',
			'item_modified' => 'Item Modified',
			'item_modified_gmt' => 'Item Modified Gmt',
			'item_content_filtered' => 'Item Content Filtered',
			'item_parent' => 'Item Parent',
			'menu_order' => 'Menu Order',
			'item_type' => 'Item Type',
			'item_mime_type' => 'Item Mime Type',
			'comment_count' => 'Comment Count',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('ID',$this->ID,true);
		$criteria->compare('item_author',$this->item_author,true);
		$criteria->compare('item_date',$this->item_date,true);
		$criteria->compare('item_date_gmt',$this->item_date_gmt,true);
		$criteria->compare('item_content',$this->item_content,true);
		$criteria->compare('item_title',$this->item_title,true);
		$criteria->compare('item_excerpt',$this->item_excerpt,true);
		$criteria->compare('item_status',$this->item_status,true);
		$criteria->compare('comment_status',$this->comment_status,true);
		$criteria->compare('item_password',$this->item_password,true);
		$criteria->compare('item_name',$this->item_name,true);
		$criteria->compare('item_modified',$this->item_modified,true);
		$criteria->compare('item_modified_gmt',$this->item_modified_gmt,true);
		$criteria->compare('item_content_filtered',$this->item_content_filtered,true);
		$criteria->compare('item_parent',$this->item_parent,true);
		$criteria->compare('menu_order',$this->menu_order);
		$criteria->compare('item_type',$this->item_type,true);
		$criteria->compare('item_mime_type',$this->item_mime_type,true);
		$criteria->compare('comment_count',$this->comment_count,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return Item the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
